Compiler setup instructions
===============================


Here are the instructions on setting up the DJGPP compiler, copyright
by DJ Delorie, from the CD-ROM in the back of this book. The CD-ROM
includes the ZIP files containing the source code for this compiler
and its associated programs, as required by the terms of the license
under which it is reproduced for this book; you can find those files
in the \djgppzip directory. You can get more recent files, or the
complete set of files for the DJGPP project, by visiting
www.delorie.com.

These instructions will work for DOS, as well as for DOS sessions
under Windows 3.1(tm) and Windows 95(tm). I have also heard that they
have been used successfully with some modifications for Windows
NT(tm); you can visit my WWW site, listed at the end of this document,
for details on those modifications, but I can't answer any questions
about them because I'm not using Windows NT. They haven't been tested
with other operating systems such as OS/2(tm). If you don't have a
printed copy of these instructions, you should print them out first.

However, before starting, I have a few comments that I will share with
you in an attempt to prevent some problems that readers of my previous
books have run into.

1. Please follow the instructions exactly. I have found that when
readers of my previous books have reported having difficulty in
setting up the compiler, in almost all cases these problems were
caused by their not following the instructions as they were written.

2. I have made these instructions as clear as possible, but they still
assume that you have a reasonable knowledge of DOS. if you don't know
enough about DOS to follow these instructions, I suggest that you get
a book like "DOS for Dummies" or find someone nearby to help you. I'll
be happy to try to help you if you have technical difficulties getting
the compiler to work, but *please* don't write to me to ask for
instructions on how to use DOS.


Now let's get to the instructions.


1. To copy the compiler from the CD-ROM to your hard disk:
   (Warning: the compiler requires approximately 20 MB of disk space!)

  a. Make a directory on your hard disk, say c:\djgpp

  b. Use XCOPY to copy all the files in the CD-ROM directory \djgpp and 
     below to your hard disk. If your CD-ROM drive is drive d: and you 
     want to install to c:\djgpp, then you can type:

xcopy d:\djgpp c:\djgpp /s

     Make sure that the letter of your CD-ROM is the same as the first
     drive letter in the xcopy line (d: in the example), and the letter 
     of the drive where you want to install the files is the same as 
     the second drive letter in the xcopy line (c: in the example).

     Note: Do *not* use "drag and drop" to copy these files from the
     CD-ROM, as that will leave them in an unmodifiable state on your 
     hard disk. This will interfere with the workings of the compiler.

  c. Add the following lines to the end of your "autoexec.bat" file,
     (but before the "win" line if you are running Windows 3.1).
     These lines assume that you want to use c: to hold temporary
     files, and that you have installed the compiler on drive C. Make
     sure that the drive letter in the line "setdjgpprun=c:" matches
     the drive letter where you have installed the compiler in step 1b.
     (To save typing, you might want to cut and paste them from this 
     file, which is \readme.txt on the CD-ROM). 

set djgpptmp=c:
set djgpprun=c:
set DJGPP=%djgpprun%\DJGPP\DJGPP.ENV
set PATH=%djgpprun%\DJGPP\BIN;%PATH%
call setdjgpp %djgpprun%\djgpp %djgpprun%/djgpp

     If you are running Windows 95 and don't have an "autoexec.bat", you
     can create one and put the above lines in it. Alternatively, you can
     create a batch file that you can call "setdos.bat" (for example),
     containing the entries from the "readme.txt" file that would go into
     "autoexec.bat" if you were running DOS and put it in whatever
     directory you like, like "c:\util". Then right-click on your "MS-DOS
     Prompt" icon, and select "Properties" and then the "Program" tab. Type
     the full name of that batch file ("c:\util\setdos.bat") into the
     "Batch file" entry in that dialog box, and it will be executed
     whenever you start an MS-DOS session through that icon.

  d. Under Windows 95, skip to step 3. Otherwise, make sure that your
     "config.sys" file contains lines that look like the following:

DEVICE=C:\DOS\HIMEM.SYS
DOS=HIGH
FILES=30

     If "config.sys" already has lines in it containing "himem.sys",
     "dos=high", and "files=nn" (when nn is at least 30), don't add the 
     lines above. Also note that "himem.sys" may be in a different 
     directory than "c:\dos"; if so, make sure that line refers to the 
     directory where "himem.sys" actually is.
     
  e. Go to step 3


2. If you prefer to run the compiler from the CD-ROM instead of
copying it to your hard disk, assuming that your CD-ROM is drive d:
and that you want to use c: to hold temporary files:

  a. Add the following lines to the end of your "autoexec.bat" file
     (but before the "win" line if you are running Windows 3.1).
     Make sure to set the drive letter in the line "set djgpprun=d:" 
     to the letter of your CD-ROM drive.
     (To save typing, you might want to cut and paste them from this 
     file, which is \readme.txt on the CD-ROM). 

set djgpptmp=c:
set djgpprun=d:
set DJGPP=%djgpprun%\DJGPP\DJGPP.ENV
set PATH=%djgpprun%\DJGPP\BIN;%PATH%
call setdjgpp %djgpprun%\djgpp %djgpprun%/djgpp

     If you are running Windows 95 and don't have an "autoexec.bat", you can
     create one and put the above lines in it. Alternatively, you can create
     a batch file that you can call "setdos.bat" (for example), containing
     the entries from the "readme.txt" file that would go into "autoexec.bat"
     if you were running DOS and put it in whatever directory you like,
     like "c:\util". Then right-click on your "MS-DOS Prompt" icon, and
     select "Properties" and then the "Program" tab. Type the full name of
     that batch file ("c:\util\setdos.bat") into the "Batch file" entry in
     that dialog box, and it will be executed whenever you start
     an MS-DOS session through that icon.

  b. Under Windows 95, skip to step 3. Otherwise, make sure that your
     "config.sys" file contains lines that look like the following:

DEVICE=C:\DOS\HIMEM.SYS
DOS=HIGH
FILES=30

     If "config.sys" already has lines in it containing "himem.sys",
     "dos=high", and "files=nn" (when nn is at least 30), don't add the 
     lines above. Also note that "himem.sys" may be in a different 
     directory than "c:\dos"; if so, make sure that line refers to the 
     directory where "himem.sys" actually is.
     

3. After making either of the above sets of changes, reboot so that they 
will take effect.


4. To check whether the compiler has been set up correctly, run the 
go32-v2.exe program by typing the following command at a DOS prompt:

go32-v2

The last two lines of its output should report how much DPMI memory and swap 
space DJGPP can use on your system, like this:

	DPMI memory available: 8020 Kb
	DPMI swap space available: 240 Kb

If you don't get output that looks like this, with the exception of different
numbers, check that you've followed the instructions exactly. 
--------------------------------------------------------------------


Copying and compiling the sample programs
=========================================

After you have set up the compiler as shown above, you should copy the
sample programs to your hard disk. They are in the directory
d:\whos\code (assuming that your CD-ROM is drive d:). 


1. To copy the sample files to your hard disk, change to the root directory 
on the CD-ROM and run the batch file "copysamp", supplying a parameter to 
indicate where you want the sample files to go. For example, if you want 
the sample files to be placed under the directory "c:\whos", type: 

d:
cd\
copysamp c:\whos


2. Now you can compile any of the sample programs by changing to the
directory "c:\whos\normal" and running the batch file "mk.bat",
giving the name of the sample program as a parameter. For example, to
compile "itemtst1", type 

mk itemtst1

The compiled version will be placed in the "\whos\normal"
directory. You can execute it by typing its name at the DOS prompt.
For example, to run "itemtst1", type  

itemtst1


The results of running itemtst1 should look like this:

Name: Chunky Chicken
Number in stock: 32
Price: 129
Distributor: Bob's Distribution
UPC: 123456789


Writing and compiling your own programs
=======================================

Change to the "\whos\code" directory on the drive where you installed
the compiler.

Use EDIT or Notepad to create a text file containing the source code
for your program, giving it the extension ".cc". In other words, if
you want your program to be called "party", then name this file
"party.cc".

To compile your program, switch to the "\whos\normal" directory and
type "mk party", substituting the name of your file for "party". Note:
do *not* add the ".cc" to the end of the file name.

To run your program normally, make sure you are in the "\whos\normal"
directory, and then type the name of the program, without the
extension. In this case, you would just type "party".

To run your program under the debugger, make sure you are in the
"\whos\normal" directory, and then type "trace party" (substituting
the name of your program for "party"). Again, do *not* add the ".cc" to
the end of the file name. Instructions for using the debugger can be
found in the text.


Further assistance
==================
If you have any problems setting up the compiler or compiling the sample
code, or have any other questions, you might want to check my web page 
for updates to the instructions or sample code. At the moment, that 
address is:

  http://www.koyote.com/users/stheller

If you can't reach that page, or you have questions that aren't
answered by it, you can email me at:

steve_heller@compuserve.com

